import { $get, $post } from '@js/authRequest'

export async function sendRequest (title, lastid) {
  const d = {
    title: decodeURIComponent(title)
  }
  if (lastid !== '') {
    d.sessionid = lastid
  }
  const res = await $post('/api/common/Chat', d)
  if (res.status === 0) {
    throw new Error(res.message || '请求失败')
  }
  return res.data
}

export async function getListRequest () {
  const res = await $get('/api/common/Chat')
  if (res.status === 0) {
    throw new Error(res.message || '请求失败')
  }
  return res.data
}

export async function getDetailRequest (id) {
  const res = await $get(`/api/common/Chat/${id}`)
  if (res.status === 0) {
    throw new Error(res.message || '请求失败')
  }
  return res.data
}
